home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP02.ZIP / CHAP02 / SCHMOO / POLYLINE.H < prev    next >
C/C++ Source or Header  |  1993-03-23  |  5KB  |  160 lines

  1. /*
  2.  * POLYLINE.H
  3.  *
  4.  * Definitions and function prototypes for the PolyLine window class
  5.  * that can be treated like its own control.
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _POLYLINE_H_
  18. #define _POLYLINE_H_
  19.  
  20. //Versioning.
  21. #define VERSIONMAJOR                2
  22. #define VERSIONMINOR                0
  23. #define VERSIONCURRENT              0x00020000
  24.  
  25. //Classname
  26. #define SZCLASSPOLYLINE             "polyline"
  27.  
  28. #define HIMETRIC_PER_INCH           2540
  29. #define CPOLYLINEPOINTS             20
  30.  
  31. //Window extra bytes and offsets
  32. #define CBPOLYLINEWNDEXTRA          (sizeof(LONG))
  33. #define PLWL_STRUCTURE              0
  34.  
  35.  
  36. //Version 2.0 Polyline Structure
  37. typedef struct __far tagPOLYLINEDATA
  38.     {
  39.     WORD        wVerMaj;                //Major version number.
  40.     WORD        wVerMin;                //Minor version number.
  41.     WORD        cPoints;                //Number of points.
  42.     BOOL        fReserved;              //Previously fDrawEntire, obsoleted
  43.     RECT        rc;                     //Rectangle of this figure (client)
  44.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points on 0-32767 grid.
  45.  
  46.     //Version 2.0 additions
  47.     COLORREF    rgbBackground;          //Background color
  48.     COLORREF    rgbLine;                //Line color
  49.     int         iLineStyle;             //Line style
  50.     } POLYLINEDATA, FAR *LPPOLYLINEDATA;
  51.  
  52. #define CBPOLYLINEDATA   sizeof(POLYLINEDATA)
  53. #define CBPOLYLINEDATA20 sizeof(POLYLINEDATA)
  54.  
  55.  
  56. //Version 1.0 Polyline Structure
  57. typedef struct __far tagPOLYLINEDATA10
  58.     {
  59.     WORD        wVerMaj;                //Major version number.
  60.     WORD        wVerMin;                //Minor version number.
  61.     WORD        cPoints;                //Number of points.
  62.     BOOL        fDrawEntire;            //Flag to draw entire figure.
  63.     RECT        rc;                     //Rectangle of this figure (parent)
  64.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points scaled to rc
  65.     } POLYLINEDATA10, FAR *LPPOLYLINEDATA10;
  66.  
  67. #define CBPOLYLINEDATA10 sizeof(POLYLINEDATA10)
  68.  
  69.  
  70. //POLYWIN.CPP
  71. LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  72.  
  73.  
  74.  
  75. class __far CPolyline : public CWindow
  76.     {
  77.     friend LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  78.  
  79.     private:
  80.         POLYLINEDATA   m_pl;
  81.  
  82.         class CPolylineAdviseSink FAR * m_pAdv;
  83.  
  84.     private:
  85.         void      PointScale(LPRECT, LPPOINT, BOOL);
  86.         void      Draw(HDC, BOOL, BOOL);
  87.         void      RectConvertMappings(LPRECT, BOOL);
  88.  
  89.     public:
  90.         CPolyline(HINSTANCE);
  91.         ~CPolyline(void);
  92.  
  93.         BOOL      FInit(HWND, LPRECT, DWORD, UINT, class CPolylineAdviseSink FAR *);
  94.  
  95.         void      New(void);
  96.         BOOL      Undo(void);
  97.  
  98.         //File functions
  99.         LONG      ReadFromFile(LPSTR);
  100.         LONG      WriteToFile(LPSTR, LONG);
  101.  
  102.         //Data transfer functions
  103.         LONG      DataSet(LPPOLYLINEDATA, BOOL, BOOL);
  104.         LONG      DataGet(LPPOLYLINEDATA, LONG);
  105.         LONG      DataSetMem(HGLOBAL, BOOL, BOOL, BOOL);
  106.         LONG      DataGetMem(LONG, HGLOBAL FAR *);
  107.         HBITMAP   RenderBitmap(void);
  108.         HMETAFILE RenderMetafile(void);
  109.         HGLOBAL   RenderMetafilePict(void);
  110.  
  111.         void      RectGet(LPRECT);
  112.         void      SizeGet(LPRECT);
  113.         void      RectSet(LPRECT, BOOL);
  114.         void      SizeSet(LPRECT, BOOL);
  115.         COLORREF  ColorSet(UINT, COLORREF);
  116.         COLORREF  ColorGet(UINT);
  117.         UINT      LineStyleSet(UINT);
  118.         UINT      LineStyleGet(void);
  119.     };
  120.  
  121. typedef CPolyline FAR * LPCPolyline;
  122.  
  123.  
  124. //Error values for data transfer functions
  125. #define POLYLINE_E_NONE                    0
  126. #define POLYLINE_E_UNSUPPORTEDVERSION      -1
  127. #define POLYLINE_E_INVALIDPOINTER          -2
  128. #define POLYLINE_E_READFAILURE             -3
  129. #define POLYLINE_E_WRITEFAILURE            -4
  130.  
  131.  
  132.  
  133.  
  134. class __far CPolylineAdviseSink
  135.     {
  136.     private:
  137.         LPVOID      m_pv;                       //Customizable structure
  138.  
  139.     public:
  140.         CPolylineAdviseSink(LPVOID);
  141.         ~CPolylineAdviseSink(void);
  142.  
  143.         void OnPointChange(void);
  144.         void OnSizeChange(void);
  145.         void OnDataChange(void);
  146.         void OnColorChange(void);
  147.         void OnLineStyleChange(void);
  148.     };
  149.  
  150. typedef CPolylineAdviseSink FAR * LPCPolylineAdviseSink;
  151.  
  152.  
  153. //Color indices for color messages
  154. #define POLYLINECOLOR_BACKGROUND    0
  155. #define POLYLINECOLOR_LINE          1
  156.  
  157.  
  158.  
  159. #endif  //_POLYLINE_H_
  160.